package com.biShe.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

import static springfox.documentation.service.ApiInfo.DEFAULT_CONTACT;

@Configuration
@EnableSwagger2   //开启swagger2
public class SwaggerConfig {

    //配置了swagger的Docket的bean实例
    @Bean
    public Docket docket1(){//该方法返回对象为Docket,并将该对象注入到Bean里面
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.biShe.controller"))
                .build();
    }

    //配置swagger的信息等于apiInfo
    private ApiInfo apiInfo(){
        //作者信息
        Contact contact = new Contact("小刘","https://gitee.com/kakaxiiii/graduation-design/tree/master","666666@qq.com");

        return new ApiInfo(
                "小刘的毕业设计",//标题
                "你好呀~欢迎来到接口测试",//描述
                "v1.0",//版本
                "https://gitee.com/kakaxiiii/graduation-design/tree/master",//组织名或者作者信息或者博客网址
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http:www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    };
}
